package com.cxy.juc;

public class SynchronizedOne {
    public static void main(String[] args) {
        TestOne testOne = new TestOne();
        Thread t1 = new Thread(testOne,"thread-1");
        Thread t2 = new Thread(testOne,"thread-2");
        t1.start();
        t2.start();
    }
}

class TestOne implements Runnable {
    @Override
    public void run() {
        synchronized (this) {
            for (int i = 0; i < 5; i++) {
                System.out.println(Thread.currentThread().getName()+"--->"+i);
            }
        }
    }
}